﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace pufflesweb.admin
{
    public partial class Agoodsupdate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string GID = Request.QueryString["GID"];

                PModel.Goods goods = PBLL.Goods.Getuser(int.Parse(GID));

                this.gname.Text = goods.Gname;
                this.gprice.Text=goods.Gprice.ToString();
                this.gnumber.Text=goods.Gnumber.ToString();
                this.gimage.Text = goods.Gimage;
                this.gtitle.Text= goods.Gtitle ;
                this.gtext.Text = goods.Gtext;
                this.gaddress.Text= goods.Gaddress ;
                this.gtype.Text=goods.Gtype.ToString() ;
                this.gstate.Text=goods.Gstate.ToString() ;
                this.HiddenField2.Value = goods.GID.ToString();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            PModel.Goods myuser = new PModel.Goods();
            myuser.Gname = this.gname.Text;
            myuser.Gprice = int.Parse(this.gprice.Text);
            myuser.Gtitle = this.gtitle.Text;
            myuser.Gtext = this.gtext.Text;
            myuser.Gaddress = this.gaddress.Text;
            myuser.Gimage = this.gimage.Text;
            myuser.Gnumber = int.Parse(this.gnumber.Text);
            myuser.Gstate = int.Parse(this.gstate.Text);
            myuser.Gtype = int.Parse(this.gtype.Text);
            myuser.GID = int.Parse(this.HiddenField2.Value);

            if (PBLL.Goods.update(myuser))
            {
                PF.JsHelper.AlertAndParentUrl("修改保存成功", "main.aspx");
            }
            else
            {
                PF.JsHelper.AlertAndParentUrl("修改失败,请重新输入", "Agoodsupdate.aspx");
            }
        }
    }
}